package com.example.juccode.juc02completableFuture.demo;

import java.util.concurrent.*;

/**
 * @author: zhongkui 1365693530@qq.com
 * @Date: 2025/2/10
 */
public class CompletableFutureBulidDemo {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        ExecutorService threadPool = Executors.newFixedThreadPool(3);

        CompletableFuture<String> completableFuture = CompletableFuture.supplyAsync(() -> {
            try {
                System.out.println(Thread.currentThread().getName() + "------开始执行");
                TimeUnit.MILLISECONDS.sleep(1000);
            } catch (Exception e) {
                e.printStackTrace();
            }
            return "hello  supplyAsync";
        });
        System.out.println(completableFuture.get());

        threadPool.shutdown();
    }
}
